package me.zhengjie.modules.other.rest;

import com.qiaofang.applet.service.other.domain.MessageList;
import com.qiaofang.applet.service.other.service.YxImMessageService;
import com.qiaofang.applet.service.other.service.dto.MessageListQueryDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.system.service.UserService;
import me.zhengjie.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author QF2019
 * @company qiaofang
 * @date 2020/9/12 11:35
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "数据管理：微聊记录")
@RequestMapping("/api/msgData")
public class MessageDataController {

    @Autowired
    private YxImMessageService yxImMessageService;

    @Autowired
    private UserService userService;

    @GetMapping("/list")
    @ApiOperation(value = "查询微聊记录列表", notes = "查询微聊记录列表")
    public ResponseEntity<Page<MessageList>> list(MessageListQueryDto queryDto, Pageable pageable) {
        //　TODO：写死登陆功能修改完成以后再去掉
        queryDto.setCorporationCode(SecurityUtils.getCorporationCode());
        queryDto.setCityCodes(userService.getCityCodeList(SecurityUtils.getCurrentUsername()));
        return ResponseEntity.ok(yxImMessageService.findMessageListByParam(queryDto, pageable));
    }
}